The present invention relates generally to the field of data communications, and more particularly, to the field of serial communications bus controllers and microcontrollers that incorporate the same.
CAN (Control Area Network) is an industry-standard, two-wire serial communications bus that is widely used in automotive and industrial control applications, as well as in medical devices, avionics, office automation equipment, consumer appliances, and many other products and applications. CAN controllers are currently available either as stand-alone devices adapted to interface with a microcontroller or as circuitry integrated into or modules embedded in a microcontroller chip. Since 1986, CAN users (software programmers) have developed numerous high-level CAN Application Layers (CALs) which extend the capabilities of the CAN while employing the CAN physical layer and the CAN frame format, and adhering to the CAN specification. CALs have heretofore been implemented primarily in software, with very little hardware CAL support. Consequently, CALs have heretofore required a great deal of host CPU intervention, thereby increasing the processing overhead and diminishing the performance of the host CPU.
Thus, there is a need in the art for a CAN hardware implementation of CAL functions normally implemented in software in order to offload these tasks from the host CPU to the CAN hardware, thereby enabling a great savings in host CPU processing resources and a commensurate improvement in host CPU performance. One of the most demanding and CPU resource-intensive CAL functions is message management, which entails the handling, storage, and processing of incoming CAL/CAN messages received over the CAN serial communications bus and/or outgoing CAL/CAN messages transmitted over the CAN serial communications bus. CAL protocols, such as DeviceNet, CANopen, and OSEK, deliver long messages distributed over many CAN frames, which methodology is sometimes referred to as xe2x80x9cfragmentedxe2x80x9d or xe2x80x9csegmentedxe2x80x9d messaging. The process of assembling such fragmented, multi-frame messages has heretofore required a great deal of host CPU intervention. In particular, CAL software running on the host CPU actively monitors and manages the buffering and processing of the message data, in order to facilitate the assembly of the message fragments or segments into complete messages.
Based on the above and foregoing, it can be appreciated that there presently exists a need in the art for a hardware implementation of CAL functions normally implemented in software in order to offload these tasks from the host CPU, thereby enabling a great savings in host CPU processing resources and a commensurate improvement in host CPU performance.
The assignee of the present invention has recently developed a new microcontroller product, designated xe2x80x9cXA-C3xe2x80x9d, that fulfills this need in the art. The XA-C3 is the newest member of the Philips XA (eXtended Architecture) family of high performance 16-bit single-chip microcontrollers. It is believed that the XA-C3 is the first chip that features hardware CAL support.
The XA-C3 is a CMOS 16-bit CAL/CAN 2.0B microcontroller that incorporates a number of different inventions, including the present invention. These inventions include novel techniques and hardware for filtering, buffering, handling, and processing CAL/CAN messages, including the automatic assembly of multi-frame fragmented messages with minimal CPU intervention, as well as for managing the storage and retrieval of the message data, and the memory resources utilized therefor. In particular, the XA-C3 CAN module has the unique ability to track and reassemble the packets constituting a fragmented message, completely in hardware, only interrupting the CPU (processor core) once a complete, multi-frame message is received and assembled. This tremendously reduces the processor bandwidth required for message handling, thereby significantly increasing available bandwidth for other tasks, so that system performance is greatly enhanced.
The present invention relates to a scheme employed by the XA-C3 microcontroller to handle a message buffer full condition in such a manner that ensures no loss of data, while minimizing the required processor intervention.
The present invention encompasses a CAN microcontroller that supports a plurality of message objects, and that includes a processor core that runs CAN applications, a plurality of message buffers associated with respective ones of the message objects, a CAN/CAL module that processes incoming messages that include a plurality of frames, each frame having a maximum number n of data bytes, and a plurality of message object registers associated with each of the message objects, including at least one buffer size register that contains a message buffer size value that specifies the size of the message buffer associated with that message object, and at least one buffer location register that contains an address pointer that points to an address of the storage location in the message buffer associated with that message object where the next data byte of the current incoming message is to be stored.
The CAN/CAL module includes a message handling function that transfers successive frames of the current incoming message to the message buffer associated with a selected one of the message objects designated as a receive message object for the current incoming message, a frame status detection function that detects whether or not the current frame of the current incoming message is the final frame of the current incoming message, and a buffer-full detection function. The buffer-full detection function, in response to a detection that the current frame of the current incoming message is not the final frame of the current incoming message, determines the number of available bytes of remaining storage capacity in the message buffer associated with the designated receive message object for the current incoming message, and declares a message buffer-full condition if the determined number of available bytes is less than the maximum number n of data bytes.
The CAN/CAL module further includes a message buffer-full interrupt generator function that generates a message buffer-full interrupt to the processor core in response to a declaration of a message buffer-full condition.
In a presently preferred embodiment, the buffer-full detection function determines the number of available bytes of remaining storage capacity in the message buffer associated with the designated receive message object for the current incoming message by subtracting prescribed bits of the address pointer contained in the at least one buffer location register associated with the designated receive message object for the current incoming message, from the message buffer size value contained in the at least one buffer size register associated with the designated receive message object for the current incoming message. Additionally, in the presently preferred embodiment, the frame status detection function detects whether the current frame of the current incoming message is the final frame of the current incoming message by deriving that information from the header portion of the current frame of the current incoming message.
In the presently preferred embodiment, the CAN/CAL module further includes a message-complete interrupt generator function that generates a message-complete interrupt to the processor core in response to the frame status detection function detecting that the current frame of the current incoming message is the final frame of the current incoming message. Additionally, in the presently preferred embodiment, the CAN/CAL module further includes an address pointer increment function that, in response to a transfer of the current data byte to the message buffer associated with the designated receive message object for the current incoming message, automatically increments the address pointer to the address of the storage location in that message buffer where the next data byte of the current incoming message is to be stored.
Preferably, the size of each message buffer can be selected by the user by programming a selected message buffer size value into the at least one message buffer size register associated with that message buffer, and the base address of each message buffer can be selected by the user by programming the address pointer associated with that message buffer to point to a selected base address.
In the presently preferred embodiment, the CAN/CAL module further includes a buffer-full handling function that, in response to a declaration of a message buffer-full condition, determines a current byte count that indicates the number of data bytes of the current incoming message that have already been stored in the message buffer associated with the designated receive message object at the time the message buffer-full condition is declared, resets the address pointer contained in the at least one buffer location register associated with the designated receive message object to the base address, writes the current byte count into the message buffer associated with the designated receive message object, in the storage location corresponding to the base address, and generates a message buffer-full interrupt.
Preferably the current CAN application running on the processor core is provided with two options as to how to respond to the message buffer-full interrupt. Under the first option, in response to the message buffer-full interrupt, the current CAN application reads the entire contents of the designated receive message buffer, and then transfers the read-out entire contents to another storage location in the data memory space, thereby freeing up the designated receive message buffer to store the at least one remaining frame of the current incoming message. Under the second option, the current CAN application, in response to the message buffer-full interrupt, modifies the base address of the designated receive message buffer by replacing the current base address with a new base address, whereby the designated receive message buffer consists of a first buffer portion starting with the current base address, and a second buffer portion starting with the new base address.
Preferably, the current CAN application, in response to the message-complete interrupt, retrieves a first number of the data bytes of the current incoming message from the first buffer portion, and retrieves a second number of the data bytes of the current incoming message from the second buffer portion, where the first number is the current byte count.